//
//  HotNewsCell.m
//  phmall
//
//  Created by admin on 2017/12/8.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "HotNewsCell.h"

@implementation HotNewsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+ (instancetype)theShareCellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"SetCell";
    HotNewsCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[HotNewsCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.title=[[UILabel alloc]init];
        [self.contentView addSubview:self.title];
        self.title.textColor=[UIColor blackColor];
        self.title.text=@"Bohol Travel:Warm Tips";
        self.title.font=[UIFont systemFontOfSize:18];
        
        self.message=[[UILabel alloc]init];
        [self.contentView addSubview:self.message];
        self.message.numberOfLines=2;
        self.message.textColor=[UIColor colorWithHexString:@"#adadad"];
        self.message.text=@"1.Almost everyone in the Philippines speaks English,but has a strong....";
        self.message.font=[UIFont systemFontOfSize:13];
        
        self.author=[UIButton buttonWithType:UIButtonTypeCustom];
        [self.author setTitle:@"admin" forState:UIControlStateNormal];
        self.author.titleLabel.font=[UIFont systemFontOfSize:15];
        [self.author setTitleColor:[UIColor colorWithHexString:@"#adadad"] forState:UIControlStateNormal];
        [self.author setImage:[UIImage imageNamed:@"作者"] forState:UIControlStateNormal];
        [self.author layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
        [self.contentView addSubview:self.author];
        
        self.click=[UIButton buttonWithType:UIButtonTypeCustom];
        [self.click setTitle:@"731" forState:UIControlStateNormal];
        self.click.titleLabel.font=[UIFont systemFontOfSize:15];
        [self.click setTitleColor:[UIColor colorWithHexString:@"#adadad"] forState:UIControlStateNormal];
        [self.click setImage:[UIImage imageNamed:@"点击量"] forState:UIControlStateNormal];
        [self.click layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
        [self.contentView addSubview:self.click];
        
        self.time=[UIButton buttonWithType:UIButtonTypeCustom];
        [self.time setTitle:@"2017.08.12" forState:UIControlStateNormal];
        self.time.titleLabel.font=[UIFont systemFontOfSize:15];
        [self.time setTitleColor:[UIColor colorWithHexString:@"#adadad"] forState:UIControlStateNormal];
        [self.time setImage:[UIImage imageNamed:@"时间"] forState:UIControlStateNormal];
        [self.time layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
        [self.contentView addSubview:self.time];
        
        self.imgView=[[UIImageView alloc]init];
        self.imgView.image=[UIImage imageNamed:@"图片"];
        ViewBorderRadius(self.imgView, 3, 1, [UIColor colorWithRed:0.93f green:0.94f blue:0.95f alpha:1.00f]);
        self.imgView.contentMode=UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:self.imgView];
        
        self.line=[UILabel new];
        self.line.backgroundColor=[UIColor colorWithRed:0.9f green:0.9f blue:0.9f alpha:1.00f];
        [self.contentView addSubview:self.line];
    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.contentView.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-10);
        make.top.offset(10);
        make.bottom.offset(-10);
        make.width.mas_equalTo(self.imgView.mas_height);
    }];
    
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.top.offset(10);
        make.right.equalTo(self.imgView.mas_left).offset(-10);
    }];
    
    [self.message mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.top.equalTo(self.title.mas_bottom).offset(5);
        make.right.equalTo(self.imgView.mas_left).offset(-10);
    }];

    [self.author mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.bottom.offset(-10);
    }];
    [self.time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.imgView.mas_left).offset(-10);
        make.bottom.offset(-10);
    }];
    [self.click mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.title);
        make.bottom.offset(-10);
    }];

    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView);
        make.left.equalTo(self.contentView);
        make.right.equalTo(self.contentView);
        make.height.mas_equalTo(0.5);
    }];
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
